package cn.cvs.controller;

import cn.cvs.pojo.HandSet;
import cn.cvs.service.HandSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class HandSetController {
    @Autowired
    private HandSetService handSetService;

    @RequestMapping(value = "/list")
    public String list(Model model){
        List<HandSet> list = handSetService.list();
        model.addAttribute("list",list);
        return "list";
    }

    @RequestMapping(value = "/listById/{hsId}")
    public String listById(Model model, @PathVariable Integer hsId){
        HandSet handSet = handSetService.listById(hsId);
        model.addAttribute("handSet",handSet);
        return "listById";
    }

    @RequestMapping(value = "/del")
    public String del(Integer hsId){
        handSetService.delete(hsId);

        return "redirect:/list";
    }

}
